import asyncio
from fastmcp import Client
from fastmcp.client.transports import SSETransport


async def weather_query():
    # 创建SSE客户端
    client = Client(SSETransport("http://localhost:8090/sse"))

    async with client:
        # 查询可用工具
        tools = await client.list_tools()
        print("可用工具:", [t.name for t in tools])

        # 调用天气查询工具
        result = await client.call_tool("query_weather", {"city_name": "杭州"})
        print("查询结果:", result[0].text)


if __name__ == "__main__":
    asyncio.run(weather_query())
